
import type { DepartData, OrderDetail, OrderListData, OrderParams, OrderPreData, OrderPreParams, OrderQuery, PayParams } from "@/types/consult"
import { request } from "@/utils/request"
import HttpRequest from "luch-request"


/**
 * 医生科室列表
 */
export const departmentListApi = () => {
  return request.get<null, DepartData[]>('/dep/all')
}
export const uploadImageApi = (filePath: string) => {
  return request.upload<null, UploadImage>('/upload', {
    name: 'file', // 服务器的 key
    filePath: filePath, // 上传文件资源的路径(沙箱路径)，上传时会自动转换成二进制
  })
}
export interface UploadImage {
  /** 图片id */
  id: string
  /** 图片地址 */
  url: string
}
/**
 * 问诊-支付页面-计算就诊信息和抵扣信息
 * @param params
 * @returns
 */
export const preOrderApi = (params: OrderPreParams) => {
  return request.get<null, OrderPreData>('/patient/consult/order/pre', { params })
}

/**
 * 问诊-保存/修改问诊订单(创建订单 -> 返回订单id -> 支付)
 */
export const createOrderApi = (data: OrderParams) => {
  return request.post<null, { id: string }>('/patient/consult/order', data)
}
// 订单通用接口
// 订单-支付接口
// POST
// /patient/consult/pay
export const payOrderApi = (data: PayParams) => {
  return request.post<null,{payUrl:string}>('/patient/consult/pay', data)
}
export const weChatPayOrderApi=(data: PayParams)=>{
return request.post<null, any>('/patient/consult/pay',data)
}
/**
 * 问诊订单详情
 */
export const orderDetailApi = (orderId: string) => {
  return request.get<null, OrderDetail>('/patient/consult/order/detail', { params: { orderId } })
}
/**
 * 评价医生
 */
export const evaluateDoctorApi = (data:RateParams) => {
  return request.post('/patient/order/evaluate', data)
}
export interface RateParams {
  /**
   * 匿名标志
   */
  anonymousFlag: number;
  /**
   * 评价内容
   */
  content: string;
  /**
   * 评价的医生id
   */
  docId: string;
  /**
   * 订单id
   */
  orderId: string;
  /**
   * 分数
   */
  score: number;
}
/**
 * 医生问诊列表
 */
export const orderListApi = (data:OrderQuery) => {
  return request.get<null, OrderListData>('/patient/consult/order/list', { params: data })
}